<script setup lang="ts">
import { reactive } from 'vue'
import {loginApi} from '@/api/loginApi'
import router from '@/router'

const userModel = reactive({
  username:'',
  loginname:'',
  password:''
})

function login() {
  loginApi(userModel).then(value => {
    if (value.data.data != null && value.data.code == 200) {
      const id = value.data.data.id
      const username = value.data.data.username
      router.push({ path: '/main', query: { id: id, username: username}})
    }
  })
}
</script>

<template>
  
  <div class="login_bg">
    <el-row>
      <el-col >
    <el-form :model="userModel" label-width="120px" style="background-color: aliceblue;padding:60px 20px 20px 20px;" size="large" >
      <el-form-item label="用户名">
        <el-input v-model="userModel.username" placeholder="请输入用户名" style="min-width: 400px;"/>
      </el-form-item>
    
      <el-form-item label="密码">
        <el-input v-model="userModel.password" size="large" placeholder="请输入密码" type="password"/>
      </el-form-item>
    
    <el-form-item>
      <el-col :span="11" :offset="6">
      <el-button type="primary" @click="login()">登  陆</el-button>
      <!-- <el-button>Cancel</el-button> -->
    </el-col>
    </el-form-item>
  </el-form>
</el-col>
</el-row>
  </div>
  
</template>

<style scoped>

.login_bg{
  background-image: url("/login_bg.jpeg");
  background-repeat: no-repeat;
  background-size: cover;
  height: 100%;
  width: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
}

</style>
